#ifndef MEMENTO_PATTERN_H
#define MEMENTO_PATTERN_H

#include <string>
#include <vector>

using namespace std;

class Memento
{
public:
    Memento(string state);
    ~Memento() {}

    string getState();

private:
    string state;
};

class Originator
{
public:
    ~Originator() {}

    void setState(string state);
    string getState();
    Memento* saveStateToMemento();
    void getStateFromMemento(Memento* memento);

private:
    string state;
};

class CareTaker
{
public:
    ~CareTaker();

    void add(Memento* state);
    Memento* get(int index);

private:
    vector<Memento*> mementoList;
};

#endif // MEMENTO_PATTERN_H

/*
    Originator* originator = new Originator();
    CareTaker* careTaker = new CareTaker();

    originator->setState("State #1");
    originator->setState("State #2");
    careTaker->add(originator->saveStateToMemento());
    originator->setState("State #3");
    careTaker->add(originator->saveStateToMemento());
    originator->setState("State #4");

    cout << "Current State : " << originator->getState() << endl;
    originator->getStateFromMemento(careTaker->get(0));
    cout << "First saved State : " << originator->getState() << endl;
    originator->getStateFromMemento(careTaker->get(1));
    cout << "Second saved State : " << originator->getState() << endl;
    */
